package interaction.game;

import processing.core.PGraphics;
import processing.core.PImage;
import processing.core.PVector;

public class LoopingGameObject extends BaseGameObject {
	private int loopDistance;

	public LoopingGameObject(PImage image, PVector position, PVector velocity, int loopDistance) {
		super(image, position, velocity);
		this.loopDistance = loopDistance;
	}
	
	public void resetPosition() {
		super.resetPosition();
		getPosition().x = getLoopDistance();
	}
	
	public int getLoopDistance()
	{
		return loopDistance;
	}

	public boolean isUpcoming() {
		PVector position = getPosition();
		PVector size = getSize();
		return ((position.x + size.x) > 0);
	}

	public void draw(PGraphics g) {
		if (!isUpcoming()) {
			resetPosition();
		}
		super.draw(g);
	}
}
